<template>
	<view class="mainpadding" >
		<u-picker :show="show" :columns="columns" :loading="loading" @confirm="confirm" @cancel="close"></u-picker>
		<u-index-list :index-list="indexList">
			<template v-for="(item, index) in itemArr">
				<!-- #ifdef APP-NVUE -->
				<u-index-anchor :text="indexList[index]"></u-index-anchor>
				<!-- #endif -->
				<u-index-item>
					<!-- #ifndef APP-NVUE -->
					<u-index-anchor :text="indexList[index]"></u-index-anchor>
					<!-- #endif -->
					<view class="list-cell" v-for="(cell, index) in item" @click="tzxxfb(cell.id,cell.name)">
						{{cell.name}}
					</view>
				</u-index-item>
			</template>
		</u-index-list>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				indexList: [],
				itemArr: [],
				fenleiid:"",
				fenleitext:"",
				loading:false,
				show:false,
				columns:[[]],
				txtbq:[],
				schoolname:'',
				schoolid:'',
			}
		},
		onLoad(options) {
			// let data = JSON.parse(decodeURIComponent(options.msg));
			// this.fenleiid = data.id
			// this.fenleitext = data.fenleitext
			this.scholllist()
		},
		methods: {
			close(){
				this.show = false
			},
			confirm(e){
				let msg = {
					xqid:this.schoolid,
					xqname:this.schoolname,
					id:this.txtbq[e.indexs[0]].id,
					fenleitext:e.value[0],
					price:this.txtbq[e.indexs[0]].spendprice
				}
				uni.navigateTo({
					url: '/pages/jishi/xinxifabu?msg='+ encodeURIComponent(JSON.stringify(msg))
				})
				this.show = false;
				// console.log(this.txtbq[e.indexs[0]],6666);
			},
			scholllist() {
				httpRequest.request('school/lists', 'POST', {
					// 传参
				}, false, false, true).then(res => {
					res.data.forEach(item=>{
						this.indexList.push(item.first)
						this.itemArr.push(item.schools)
					})
					// console.log(this.indexList,888)
					// console.log(this.itemArr,999)
					// this.itemArr = res.data
				})
			},
			//跳转信息发布页面
			tzxxfb(id,name) {
				this.schoolid = id;
				this.schoolname = name;
				httpRequest.request('topic/lists','POST',{
					other_school_id:id
				}).then(res => {
					this.txtbq = [];
					this.columns = [[]];
					this.txtbq = res.data;
					for(let i = 0; i < res.data.length; i++){
						this.columns[0].push(res.data[i].name);
					}
					console.log(this.columns)
					this.show = true;
				})
			}
		}
	}
</script>


<style lang="scss" scoped>
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}
</style>
